using System;
using UnityEngine;


//        N(-Y)
//  				E(X)
//	  		    
//  	W(-X)
//	             S(Y)

public enum SAMapDirectionType
{
	NORTH = 3,
	SOUTH = 7,
	WEST = 1,
	EAST = 5,
	
	NORTHWEST = 2,
	NORTHEAST = 4,
	SOUTHWEST = 0,
	SOUTHEAST = 6,
	
	COUNT = 8
}


public class SAMapDirection
{

	
	public static int getReverseDirection( int direct )
	{
		switch ( direct ) 
		{
		case (int)SAMapDirectionType.SOUTHEAST:
			return (int)SAMapDirectionType.NORTHWEST;
		case (int)SAMapDirectionType.SOUTHWEST:
			return (int)SAMapDirectionType.NORTHEAST;
		case (int)SAMapDirectionType.NORTHWEST:
			return (int)SAMapDirectionType.SOUTHEAST;
		case (int)SAMapDirectionType.NORTHEAST:
			return (int)SAMapDirectionType.SOUTHWEST;
		case (int)SAMapDirectionType.SOUTH:
			return (int)SAMapDirectionType.NORTH;
		case (int)SAMapDirectionType.NORTH:
			return (int)SAMapDirectionType.SOUTH;
		case (int)SAMapDirectionType.EAST:
			return (int)SAMapDirectionType.WEST;
		case (int)SAMapDirectionType.WEST:
			return (int)SAMapDirectionType.EAST;
			
		}
		
		return (int)SAMapDirectionType.COUNT;
	}

	public static int GetDirection( SAMapGrid pos1 , SAMapGrid pos2 )
	{
		int x = pos1.posX - pos2.posX;
		int y = pos1.posY - pos2.posY;
		
		int direction = (int)SAMapDirectionType.COUNT;
		
		if ( x > 0 && y > 0 ) 
			direction = (int)SAMapDirectionType.SOUTHEAST;
		else if ( x > 0 && y == 0 ) 
			direction = (int)SAMapDirectionType.EAST;
		else if ( x > 0 && y < 0 ) 
			direction = (int)SAMapDirectionType.NORTHEAST;
		else if ( x == 0 && y < 0 ) 
			direction = (int)SAMapDirectionType.NORTH;
		else if ( x < 0 && y < 0 ) 
			direction = (int)SAMapDirectionType.NORTHWEST;
		else if ( x < 0 && y == 0 ) 
			direction = (int)SAMapDirectionType.WEST;
		else if ( x < 0 && y > 0 ) 
			direction = (int)SAMapDirectionType.SOUTHWEST;
		else if ( x == 0 && y > 0 ) 
			direction = (int)SAMapDirectionType.SOUTH;
		
		return direction;
	}

	public SAMapDirection ()
	{
	}


}